//
//  BKUserNewAboutBestKeepController.m
//  bestkeep
//
//  Created by windCould on 17/1/4.
//  Copyright © 2017年 utouu. All rights reserved.
//

#import "BKUserNewAboutBestKeepController.h"
#import "BKMyCommon.h"
#import "BKSecondBKBriefController.h"

@interface BKUserNewAboutBestKeepController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong) UITableView * bestTabelView;
@property(nonatomic,strong) NSString * version;
@end

//static int scountNum=0;

@implementation BKUserNewAboutBestKeepController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"关于BESTKEEP";
    
    self.view.backgroundColor = RGBACOLOR(242, 242, 242,1);
    self.bestTabelView = [[UITableView alloc]initWithFrame:self.view.bounds];
    self.bestTabelView.delegate = self;
    self.bestTabelView.dataSource = self;
    self.bestTabelView.backgroundColor = RGBACOLOR(242, 242, 242,1);
    self.bestTabelView.separatorStyle = UITableViewCellSelectionStyleNone;
    [self.view addSubview:self.bestTabelView];
    
    
    NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
    self.version = [NSString stringWithFormat:@"%@",[infoDict objectForKey:@"CFBundleShortVersionString"]];
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 3;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        
        return 183;
        
    } else if (indexPath.row ==1){
        
        return 40;
    } else if (indexPath.row ==2){
 
        return ScreenHeight -183-64-40;
    }
    
    return 0;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * cellId = @"settingcell";
    
    UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:cellId];
    
    if (cell==nil) {
        
        cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
    }
    if (indexPath.row==0) {
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.contentView.backgroundColor=RGBACOLOR(242, 242, 242,1);
        
        UIImageView *bestlogo_view = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"BK_My_liantu copy"]];
        UIImage *bestlogo_image = [UIImage imageNamed:@"BK_My_liantu copy"];
        [cell.contentView addSubview:bestlogo_view];
        
        [bestlogo_view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(cell.contentView.mas_centerX);
            make.top.equalTo(cell.contentView.mas_top).mas_offset(20);
            make.height.equalTo(@(bestlogo_image.size.height));
            make.width.equalTo(@(bestlogo_image.size.width));
        }];
        
        UILabel*title_label = [UILabel new];
        title_label.text = @"扫描二维码，分享BESTKEEP客户端给您的朋友吧！";
        title_label.textColor = HexColor(0x444444);
        title_label.font = UIFontSmall;
        [cell.contentView addSubview:title_label];
        
        
        [title_label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(bestlogo_view.mas_bottom).mas_offset(16);
            make.centerX.equalTo(bestlogo_view.mas_centerX);
        }];
        
    }else if (indexPath.row == 1){
        
        cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
        UILabel *tile =[UILabel new];
        tile.text =@"BESTKEEP 简介";
        tile.textColor = HexColor(0x404040);
        tile.font = [UIFont systemFontOfSize:15];
        [cell.contentView addSubview:tile];
        
        [tile mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(cell.contentView.mas_left).mas_offset(ApplicationBackGauge);
            make.centerY.equalTo(cell.contentView.mas_centerY);
        }];
        
    }else if (indexPath.row ==2){
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.contentView.backgroundColor = RGBCOLOR(242, 242, 242,1);
        UIControl *control = [[UIControl alloc]init];
        [control addTarget:self
                    action:@selector(onClick)
          forControlEvents:UIControlEventTouchUpInside
         ];
        [cell.contentView addSubview:control];
        
        [control mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(cell.contentView.mas_centerX);
            make.top.equalTo(cell.contentView.mas_top).mas_offset(20);
            make.height.equalTo(@(50));
            make.width.equalTo(@(50));
        }];
        
        
        UIImageView *imageview =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"BK_My_logo_image"]];
        [cell.contentView addSubview:imageview];
        [imageview mas_makeConstraints:^(MASConstraintMaker *make) {
           
            make.centerX.equalTo(cell.contentView.mas_centerX);
            if (ScreenHeight>700) {
                
                make.top.equalTo(cell.contentView.mas_bottom).mas_offset(-167);
            }else if (ScreenHeight>600){
                
                make.top.equalTo(cell.contentView.mas_bottom).mas_offset(-160);
            }else if(ScreenHeight>500){
                
                make.top.equalTo(cell.contentView.mas_bottom).mas_offset(-150);
            }else{
                
                make.top.equalTo(cell.contentView.mas_bottom).mas_offset(-130);
            }
            make.height.equalTo(@(50));
            make.width.equalTo(@(50));
        }];
        
        UILabel *version_label =[UILabel new];
        [version_label setFont:[UIFont systemFontOfSize:11]];
        version_label.textColor=RGBCOLOR(136, 136, 136,1);
        version_label.text =[NSString stringWithFormat:@"当前版本号: %@",APP_VERSION];
        [cell.contentView addSubview:version_label];
        
        [version_label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(imageview.mas_centerX);
            make.top.equalTo(imageview.mas_bottom).mas_offset(18);
        }];
        
        
        UILabel *lab_UTSOFT =[UILabel new];
        lab_UTSOFT.textColor=RGBCOLOR(204, 204, 204,1);
        [lab_UTSOFT setFont:[UIFont systemFontOfSize:11]];
        lab_UTSOFT.text =@"悠唐软件(UTSOFT.CN)提供技术支持 ";
        [cell.contentView addSubview:lab_UTSOFT];
        
        
        [lab_UTSOFT mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(imageview.mas_centerX).offset(13);
            make.top.equalTo(version_label.mas_bottom).mas_offset(13);
        }];
        
    
        UIImageView *imgV_icon =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"BK_My_UTSOFT_icon_"]];
        [cell.contentView addSubview:imgV_icon];
        [imgV_icon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(lab_UTSOFT.mas_centerY);
            make.right.equalTo(lab_UTSOFT.mas_left).offset(-5);
            make.height.equalTo(@(13));
            make.width.equalTo(@(13));
        }];
        
        
    }
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (indexPath.row ==1) {
        
        BKSecondBKBriefController *briefVC  = [[BKSecondBKBriefController alloc]init];
        [self.navigationController pushViewController:briefVC animated:YES];
    }
    
}

-(void)onClick{
    
}



@end
